<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Str;

class FmwBBCController extends Controller
{
    protected $methodFunctions = [
        '1261' => 'entryOrder',
        '1262' => 'deliveryOrder',
        '1266' => 'inventoryAdjust',
        '1263' => 'orderOrRefund',
        '1267' => 'inventoryDaily',
        '1264' => 'orderAmountDaily',
        '1265' => 'refundAmountDaily',
        '1260' => 'products',
        '1258' => 'suppliers',
    ];

    public function index(Request $request)
    {
        $script = $request->get('script', 0);
        $method = $this->methodFunctions[$script] ?? '';
        if (empty($script)) {
            return [];
        }

        return $this->$method($request);
    }

    // 拉取商品
    public function products()
    {
        $unit = '件';
        $internalid = '337306';
//        $internalid = rand(100000, 999999);

        $upcCode = '';
        $upcCode = 'BBC_SKU' . $internalid;

        $item = [
            "internalid" => $internalid,
            "itemid" => "Nola推广组套" . $internalid,
            "upccode" => $upcCode,
            "type" => "InvtPart",
            "Inactive" => "否",
            "displayname" => "Nola Introduction Kit",
            "unitstype" => $unit,
            "purchaseunit" => $unit,
            "stockunit" => $unit,
            "saleunit" => $unit,
            "consumptionunit" => $unit,
            "custitem1" => "2024/06/14 1:38:56 pm",
            "subsidiary" => "BBC New Holdings, LLC  => BBC - China",
            "department" => "",
            "location" => "",
            "custitem_fullcode" => date('Ymd') . $internalid,
            "custitem_validdate" => '15', // 0 - sku; 1 -GUARANTEE 保质期天数
            "custitem_minoq" => "",
            "custitem_minorderquantity" => "",
            "custitem_havi_reorderpoint" => "",
            "custitem_de_vendor" => "",
            "custitem_item_type" => "Merchandise",
            "custitem_lead_value" => "",
            "custitem_chinese_name" => "Nola推广组套" . $internalid,
            "custitem_need_count" => "否",
            "custitemcreatedsub" => "BBC New Holdings, LLC  => BBC - China",
            "custitem_item_en_name" => "Nola Introduction Kit",
            "custitem_retail_charge" => "是",
            "custitem_noadj" => "否",
            "custitem2" => "否",
            "custitem_temarea" => "常温",
            "custitem_hc_bomguige" => "",
            "custitem_hp_conversationrate" => "1",
            "custitem_hc_ecrate" => "",
            "custitem_hc_yunfaqi" => "",
            "custitem_hc_wenduleixing" => "3",
            "custitem_hc_xianggui" => "",
            "custitem_hc_chang" => "",
            "custitem_hc_kuan" => "",
            "custitem_hc_gao" => "",
            "custitem_hc_zhongliang" => "",
            "custitem_hc_songhuoleixing" => "Dry",
            "custitem_hc_noyaohuo" => "否",
            "custitem_kucun_base_rate" => "1",
            "assetaccount" => "Inventory Merchandise",
            "incomeaccount" => "Merchandise",
            "cogsaccount" => "Merchandise",
            "billpricevarianceacct" => "Merchandise",
            "billqtyvarianceacct" => "Merchandise",
            "tracklandedcost" => "是",
            "taxschedule" => "CN-SO13%PO13%",
            "custitem_production_pandian" => "否",
            "custitem_hc_pro_exp" => "是",
            "custitem_hc_danweimiaoshu" => ""
        ];

        return [
            'status' => '100',
            'errorMessage' => '描述内容',
            'data' => [$item],
        ];
    }

}
